package cn.itsource.ymcc.domain;

import cn.itsource.ymcc.constant.RConst;
import cn.itsource.ymcc.dto.UserRegisterDto;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;

import java.time.LocalDateTime;
import java.io.Serializable;
import java.util.Date;

/**
 * <p>
 * 会员登录账号
 * </p>
 *
 * @author whale.chen
 * @since 2024-06-11
 */
@Data
@TableName("t_user")
public class User extends Model<User> {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    private Date createTime;

    private Date updateTime;

    /**
     * 三方登录名
     */
    private String thirdUid;

    /**
     * 手机号
     */
    private String phone;

    /**
     * 邮箱
     */
    private String email;

    /**
     * 昵称
     */
    private String nickName;

    /**
     * 用户状态
     */
    private Long bitState;

    /**
     * 安全级别
     */
    private Integer secLevel;

    private Long loginId;

    public static User of(UserRegisterDto userRegisterDto){
        User user = new User();
        user.setCreateTime(new Date());
        user.setThirdUid(userRegisterDto.getPhone());
        user.setPhone(userRegisterDto.getPhone());
        user.setEmail(null);
        user.setNickName(userRegisterDto.getPhone());
        user.setBitState(RConst.Num.BASE_LONG_0);//后面在说 todo
        user.setSecLevel(RConst.Num.INT_0);//后面在说 todo
        user.setLoginId(null);//后面在说 todo
        return user;
    }



}
